package apiv1

import (
	"github.com/gin-gonic/gin"
	"go-shop-api/internal/service"
	"net/http"
)

//验证码

// GetCaptcha 获取验证码
func GetCaptcha(c *gin.Context) {
	var captchaService *service.CaptchaService
	//获取验证码
	res := captchaService.GetVerifyCode()
	c.JSON(http.StatusOK, res)
}

// CheckCaptcha post 验证验证码
func CheckCaptcha(c *gin.Context) {
	var captchaService *service.CaptchaService
	//验证
	if err := c.ShouldBind(&captchaService); err != nil {
		//返回验证器验证的错误信息
		c.JSON(http.StatusOK, Validators(err))
		return
	}

	res := captchaService.CheckVerifyCode()
	c.JSON(http.StatusOK, res)
}
